package com.hao.syn;

import java.util.Arrays;

public class UnSafeBuyTicket {

    public  static void main(String[] args)  {
        BuyTicket buyTicket = new BuyTicket();
        for (String s : Arrays.asList("世浩", "浩浩")) {
            new Thread(buyTicket, s).start();
        }
    }
}
class BuyTicket implements Runnable{
    private int ticketNums = 10;
    @Override
    public void run() {
        while (true){
            // 买票
            if (ticketNums<=0) break;
            System.out.println(Thread.currentThread().getName()+"买到了第"+ticketNums--+"票");
        }
    }
}
